package com.huike.controller.system;

import com.huike.dto.DictTypePagDto;
import com.huike.entity.SysDictType;
import com.huike.result.Result;
import com.huike.service.DictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/system/dict")
/**
 * 用于查询字典类型表
 */
public class DictController {
    @Autowired
    private DictService dictService;
    /**
     * 字典分页查询
     */
    @GetMapping("/type/list")
    public Result listDictType(DictTypePagDto dto){
      return   dictService.listDictType(dto);
    }

    @PostMapping("/type/create")
    public Result createDictType(@RequestBody SysDictType sysDictType){
        return   dictService.createDictType(sysDictType);
    }

    /**
     * 回显
     * @param id
     * @return
     */
    @GetMapping("/type/{id}")
    public Result findById(@PathVariable Long id){
        return   dictService.findById(id);
    }

    @PutMapping("/type/update")
    public Result updateDictType(@RequestBody SysDictType SysDictType){
        return   dictService.updateDictType(SysDictType);
    }

    @DeleteMapping("/type/delete/{id}")
    public Result deleteById(@PathVariable Long id){
      return   dictService.deleteById(id);
    }


}
